package com.wei.controller;

import com.wei.pojo.BaseResult;
import com.wei.pojo.Tb_goods;
import com.wei.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/goods")
@CrossOrigin
public class GoodsController {

    @Autowired
    GoodsService goodsService;

    @RequestMapping("/findAll")
    public BaseResult findAll(Integer page,Integer size) {
        BaseResult all = goodsService.findAll(page, size);
        return all;
    }
    @RequestMapping("/findById")
    public Tb_goods findById(Integer id){
        return goodsService.findById(id);
    }
    @RequestMapping("/deleteById")
    public int delete(Integer id){
        return goodsService.deleteById(id);

    }
    @RequestMapping("/updateOrSave")
    public int updateOrSave(@RequestBody Tb_goods tb_goods){
        return goodsService.saveOrUpdate(tb_goods);
    }

}
